﻿using mesan.crosscutting.IoC;
using StructureMap;
using StructureMap.Configuration.DSL;

namespace mesan.core
{
	public class StructureMapContainer : IDiContainer
	{
		public StructureMapContainer(Registry registry)
		{
			if (registry == null)
				registry = new DefaultRegistry();

			ObjectFactory.Initialize(o => o.AddRegistry(registry));
		}

		public TInstance Get<TInstance>() where TInstance : class
		{
			return ObjectFactory.GetInstance<TInstance>();
		}
	}
}
